angular.module('Controller')
.directive('qgyApartmentItem',[()->
    return {
        restrict:'E'
        replace:true
        scope:{
            apmData:'=apmData'
            apmList:'=apmList'
            apmParam:'@apmParam'
            pickApartment:'&pickApartment'
        }
        templateUrl:'templates/common-directive/apartment-item/apartment-item.html'
        controller:'QgyApartmentItemCtrl'
    }
])

.controller 'QgyApartmentItemCtrl',(urls,$scope,wfAlert,userData,commonConstant,$http,$localStorage)->
    $scope.storeAu=userData.getStore()
    $scope.apartmentList=$scope.apmList #JSON.parse($scope.apmList)
    $scope.apartmentParam=theParam=$scope.apmParam || 'apartmentId'
    console.log('$scope.apartmentList',$scope.apartmentList)
    if $scope.storeAu!=undefined
#        $scope.apmData[theParam]=$scope.storeAu if $scope.apmData[theParam]!=$scope.storeAu
        tmp=_.find($scope.apartmentList,(item)->item.id== $scope.apmData[theParam])
        $scope.storeName=if tmp then tmp.name else '未知门店'
